<#include "../../common/_header.htm">
<div id="hidebox" style="height:100%;width:100%">
    <button class="exportDetail">导出</button>
    <div class="box-body table-responsive">
        <table id="table" class="table text-nowrap"></table>
    </div>
</div>
<script>
    $(function() {
        /** 回去传值 **/
        var dialog = top.dialog.get(window);
        var data = dialog.data; // 获取对话框传递过来的数据
        $('#table').datagrid({
            url: '${ctx}/eachOtherCall/eachOtherDetails',
            fitColumns:true,
            // left:'2%',
            // width:'95%' ,
            height:($(window).height())-50,
            queryParams:data ,
            pageNumber:1,
            pageSize:30,
            pageList:[30,50,100,150,200],
            pagination:true,
            rownumbers: true,//行号
            columns: [[
                {
                    field: 'serviceNumber',
                    //域值
                    title: '主叫号码',
                },
                {
                    field: 'callType',
                    //域值
                    title: '呼叫类型',
                    //标题
                    visible: true,
                    formatter: function(value, row, index) {
                        if (value==0) {
                            return '主叫';
                        } else {
                            return '被叫';
                        }
                    },
                    sortable: true
                },
                {
                    field: 'partyNumber',
                    //域值
                    title: '对方号码',
                },
                {
                    field: 'partyLocation',
                    //域值
                    title: '对方号码归属地',
                },
                {
                    field: 'startingTime',
                    //域值
                    title: '通话日期',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if(value){
                            var date = new Date(value);
                            return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
                        }else{
                            return '-';
                        }
                    }
                },
                {
                    field: 'talkTime',
                    //域值
                    title: '通话时长(秒)',
                    sortable: true
                },
                {
                    field: 'cid',
                    //域值
                    title: '基站号（CI）',
                },
                {
                    field: 'lac',
                    //域值
                    title: '小区号（LAC）',
                },
                {
                    field: 'address',
                    //域值
                    title: '地址',
                }
            ]],
            onLoadSuccess:function (result) {

            }
        });
        $('button').on('click',function () {
            console.log(data);
            var xhr = new XMLHttpRequest();
            var url="${ctx}/eachOtherCall/eachOtherDetailsExcel";
            xhr.open('POST', url, true);
            xhr.responseType = "blob";  // 返回类型blob
            // 定义请求完成的处理函数
            xhr.onload = function () {
                // 请求完成
                if (this.status === 200) {
                    var content = this.response;
                    var aTag = document.createElement('a');
                    var blob = new Blob([content]);
                    var headerName = xhr.getResponseHeader("Content-disposition");
                    var fileName = decodeURIComponent(headerName).substring(21);
                    aTag.download = fileName;
                    aTag.href = URL.createObjectURL(blob);
                    aTag.click();
                    URL.revokeObjectURL(blob);
                }
            };
            xhr.setRequestHeader("Content-type","application/json");
            xhr.send(JSON.stringify(data));

        });
    });
</script>
<style>
    button.exportDetail {
        position: absolute;
        bottom: 0px;
        left: 50%;
        transform: translateX(-50%);
        background-color: #23B7E5;
        border-color: #23B7E5;
        width: 70px;
        height: 30px;
        color: #fff;
        border-color: transparent;
        cursor: pointer;
        border-radius: 4px;
    }
    #hidebox {
        top: 23px;
        left: 2%;
        border-radius: 5px;
        background-color:#fff;
        z-Index:9999;
        padding: 10px;
        overflow:hidden;
    }
    .box-body.table-responsive {
        height: 100%;
    }
    .fixed-table-pagination {
        margin-top: 15px;
    }
</style>
</body>
</html>
